/**
 * Created by hongwen on 2017/9/13. 短信&&闪信
 * docs: http://115.29.170.239:8081/wangyn/yunkefu-docs/blob/master/config/sms.md
 */
import send from '../../http'
export default {
  /**
   * 获取挂机短信
   * @param
   * @returns {*}
   */
  queryHangupMessageTemplate (data) {
    let req = {
      data: data,
      action: 'app.sms.queryHangupMessageTemplate'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 保存挂机短信配置
   * @param
   * @returns {*}
   */
  saveCallMessageTemplate (data) {
    let req = {
      data: data,
      action: 'app.sms.saveCallMessageTemplate'
    }
    return send.fetch(req, 'post')
  },
  /**
   * 闪信模板: 查询列表
   * data:{"account":"N00000000531", page:1 ,limit:0 }
   * **/
  queryFlashSmsExamine (data) {
    let req = {
      data: data,
      byBill: true,
      page: data.page,
      limit: data.limit,
      action: 'bill.resource.queryFlashSmsExamine'
    }
    return send.fetchByBill(req, 'post')
  },
  /**
   * 获取可用通道
   * data:{"type":"flashSmsChannel"}
   * **/
  getClientDicCache (data) {
    let req = {
      data: data,
      action: 'bill.system.getClientDicCache'
    }
    return send.fetchByBill(req, 'post')
  },
  /**
   * 新建闪信模版
   * @param data.account String 账户
   * @param data.name String 模版名称
   * @param data.content String 模版内容
   * @param data.channel String 通道id
   * @returns {*}
   */
  addShanxinTemplete (data) {
    let req = {
      data,
      action: 'bill.resource.addShanxinTemplete'
    }
    return send.fetchByBill(req, 'post')
  },
  /***
   * 根据_id获取闪信模板详情(修改前的回显)
   * data:{"_id":"N000000005310017"} 模板id
   * **/
  getShanxinTempleteById (data) {
    let req = {
      data: data,
      action: 'bill.resource.getShanxinTempleteById'
    }
    return send.fetchByBill(req, 'post')
  },
  /***
   * 更新单个闪信模块(修改后的保存)
   data: {
        "account":"账户id",
        "_id":"模板id",
        "num":"17",
        "name":"模版名称"
        "content":"模版内容",
        "channel":"通道"
    }
   * **/
  updateShaninTemplete (data) {
    let req = {
      data: data,
      action: 'bill.resource.updateShaninTemplete'
    }
    return send.fetchByBill(req, 'post')
  },
  /***
   * 删除单个闪信模块
   * data:{"_id":"N000000005310017"}
   * **/
  deleteShanxinTemplete (data) {
    let req = {
      data: data,
      action: 'bill.resource.deleteShanxinTemplete'
    }
    return send.fetchByBill(req, 'post')
  },
  /***
   * 停用或启用闪信模板
     data:{
        "_id":"N000000005310009",
        "status":"stop" // "open" 是启动 "stop" 是停用
     }
   **/
  changeShanxinTemplete (data) {
    let req = {
      data: data,
      action: 'bill.resource.changeShanxinTemplete'
    }
    return send.fetchByBill(req, 'post')
  },
  /***
   * 闪信模板  签名
   data::{"account":"N00000001366"}
   **/
  queryShanxinSign (data) {
    let req = {
      data: data,
      action: 'bill.resource.queryShanxinSign'
    }
    return send.fetchByBill(req, 'post')
  }
}
